<?php

class Control_Gm_setServerStateAjax
{
    function setServerStateAjax()
    {

        $state = MooForm::post('state');
        $serverIds = trim(MooForm::post('serverIds'),',');

        $sendUrl = MooConfig::get('main.url.serverManager');
        $url = $sendUrl . "?pwd=fire1&&type=changeServerState&serverIds={$serverIds}&state={$state}";
        $res = MooUtil::curl_request($url);

        $servers = MooJson::decode($res, true);
        foreach ($servers['servers'] as $key => $value){
            switch ($value['state']){
                case 1:
                    $servers['servers'][$key]['stateText'] = "<font style='color:grey'>维护中</font>";
                    break;
                case 2:
                    $servers['servers'][$key]['stateText'] = "<font style='color:green'>新服</font>";
                    break;
                case 3:
                    $servers['servers'][$key]['stateText'] = "<font style='color:red'>火爆</font>";
                    break;
                case 4:
                    $servers['servers'][$key]['stateText'] = "<font style='color:white'>白名单</font>";
                    break;
            }
        }
        $resData = array('code'=>0,'message'=>'success','data'=>$servers['servers']);
        $rs = MooJson::encode($resData);
        exit($rs);

    }

}